function [ hasil,hasil2 ] = y_RK32( f, x0, y0, y1, b, h )
%Y_RK3 Summary of this function goes here
%   Menghitung y(b) dengan metode Runge-Kutta orde tiga pada PDB
%   y' = f(x,y); y(x0)=y0
    n = (b - x0)/h; %jumlah langkah
    y = y0;
    x = x0;
    y2 = y1;
    syms a b c;
    for r = 2 : n+1
        k1 = h * y2 + h * h * subs(f, [a b c], [x y y2]) / 2;
        
        k2 = h * y2 + h * h * subs(f, [a b c], [(x + h / 2) (y + k1 / 2) y2]) / 2;
        
        k3 = h * y2 + h * h * subs(f, [a b c], [(x + h) (y - k1 + 2 * k2) y2]) / 2;
        
        k4 = h * subs(f, [a b c], [x y y2]);
        
        k5 = h * subs(f, [a b c], [(x + h / 2) (y + k4 / 2) y2]);
        
        k6 = h * subs(f, [a b c], [(x + h) (y - k4 + 2 * k5) y2]);
        
        y = y + (k1 + 4 * k2 + k3) / 6;
        y2 = y2 + (k4 + 4 * k5 + k6) / 6;
        x = x + h;
    end
    hasil = y;
    hasil2 = y2;
end

